package cn;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 *
 */
public class test {

    public static void main(String[] args) {
        System.out.println(execCMD("jmap -histo:live  129172"));
    }

    public static String execCMD(String command) {
        StringBuilder sb = new StringBuilder();
        try {
            Process process = Runtime.getRuntime().exec(command);
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                sb.append(line + "\n");
            }
        } catch (Exception e) {
            return e.toString();
        }
        return sb.toString();
    }
}
